package com.cx.controller;

import com.cx.entity.Dept;
import com.cx.service.DeptService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

//Controller 里面写实现的方法，测试也是测试Controller不测试别的 @Data就类似于getter,setter 让引入的属性可以被识别使用
@Data
@org.springframework.stereotype.Controller
public class Controller {
    @Autowired
    //    将DeptService 接口当成属性引入
    private DeptService deptService;

    //    查询一个
    public Dept getDeptById(int id) {
        Dept deptById = deptService.getDeptById(id);
        return deptById;
    }

    // 修改
    public String updateDept(Dept dept) {
        Boolean b = deptService.updateDept(dept);
        return b ? "修改成功" : "修改失败";
    }


    // 删除
    public String deleteDeptById(int id) {
        Boolean b = deptService.deleteDeptById(id);
        return b ? "删除成功" : "删除失败";
    }

    // 新增
    public String insertDept(Dept dept) {
        Boolean b = deptService.insertDept(dept);
        return b ? "添加成功" : "添加失败";
    }


}
